﻿using System.Reflection;

namespace System
{
    static public class TypeExtention
    {
        #region Static public methods

        static public object Create(this Type type)
        {
            ConstructorInfo ctor = type.GetConstructor(new Type[0]);

            if (ctor == null)
                throw new InvalidOperationException(
                    string.Format("Type '{0}' does not have parameterless constructor.", type.FullName));

            return ctor.Invoke(null);
        }

        #endregion
    }
}